www.gusucode.com > PHP版金融投资类企业PHP源码程序 > PHP版金融投资类企业/公司网站系统源码 v1.0/IVEARS_v1.0/IVEARS_v1.0/Lib/TagLib/TagLibArticle.class.php

    <?php
class TagLibArticle extends TagLib{
    protected $tags = array(
         'Article' => array('attr' => 'limit,order','close' =>1)// attr 属性列表close 是否闭合(0 或者1 默认为1,表示闭合)
 	);
 public function _Article ($attr,$content){
       $attr = $this->parseXmlAttr($attr);
       $limit=$attr['limit'];//参数$limit,可通过模板传入参数值
       $order=$attr['order'];//$order$limit,可通过模板传入参数值
	   $cid=$attr['cid'];
	   $id=$attr['id'];
	   if($cid){
		  	$where="cid=$cid";
	   }
		if($id){
			$where="id=$id";
		}
       $str='<?php ';
       $str .= '$field=array("id","cid","title","create_time","content");';//定义需要调用的字段
       $str .= '$_list_news=M("Article")->field($field)->where("'.$where.'")->limit('.$limit.')->order("'.$order.'")->select();';//查询语句
       $str .= 'foreach ($_list_news as $_list_value):';
       $str .= 'extract($_list_value);';
       $str .= '$url=U("read/".$id);?>';//自定义文章生成路径$url
       $str .= $content;
       $str .='<?php endforeach ?>';
       return $str;
       }
 }